package com.bing.java.digui;

/**
 * 递归算法
 * @author bing
 *
 * 2019年11月12日 上午8:55:49
 */
public class DiguiAgeExample {

	public static void main(String[] args) {
//		int num = 0;
//		int a = 10;
//		int b = 2;
//		Integer lastAge = lastAge(num, a, b);
//		System.out.println(lastAge);
		System.out.println(computeAge(8));
	}

	public static Integer lastAge(int num, int a, int b) {
		b = a + b;
		a = b;
		b = 2;
		if (num < 8) {
			num++;
			System.out.println("第" + num + "人年龄是" + a);
			lastAge(num, a, b);
			if (num == 8) {
				return a;
			}
		}
		if (num == 8) {
			return a;
		}
		return b;
	}

	public static int computeAge(int n) {
		if (n == 1)
			return 10;
		return computeAge(n - 1) + 2;
	}
}
